package com.pro.springbootshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pro.springbootshop.entity.Orders;
import com.pro.springbootshop.entity.Wares;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface OrderMapper extends BaseMapper<Orders> {
    @Select("select * from orders where buyer_id=#{buyerId} limit #{pageNo},#{limit}")
    @Results(
            {
                    @Result(column = "order_id",property = "orderId"),
                    @Result(column = "wares_id",property = "waresId"),
                    @Result(column = "buyer_id",property = "buyerId"),
                    @Result(column = "wares_number",property = "waresNumber"),
                    @Result(column = "order_time",property = "orderTime"),
                    @Result(column = "order_state",property = "orderState"),
                    @Result(column = "wares_id",property = "wares",javaType = Wares.class,
                            one=@One(select = "com.pro.springbootshop.mapper.WaresMapper.selectById")
                    )
            }
    )
    List<Orders> getOrderList(String buyerId, Integer pageNo, Integer limit);
    @Select("select * from orders where buyer_id=#{buyerId}")
    List<Orders> getOrderListCount(String buyerId);
    @Select("select * from orders limit #{pageNo},#{limit}")
    @Results(
            {
                    @Result(column = "order_id",property = "orderId"),
                    @Result(column = "wares_id",property = "waresId"),
                    @Result(column = "buyer_id",property = "buyerId"),
                    @Result(column = "wares_number",property = "waresNumber"),
                    @Result(column = "order_time",property = "orderTime"),
                    @Result(column = "order_state",property = "orderState"),
                    @Result(column = "wares_id",property = "wares",javaType = Wares.class,
                            one=@One(select = "com.pro.springbootshop.mapper.WaresMapper.selectById")
                    )
            }
    )
    List<Orders> sellerGetOrderList(Integer pageNo, Integer limit);
}
